using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace PlainConcepts.Fx.Dnie.DigitalSign.Configuration
{
	/// <summary>
	/// Collection of plugins to sign documents 
	/// </summary>
	public class DigitalSignerElementCollection
		: ConfigurationElementCollection
	{
		/// <summary>
		/// ConfigurationElementCollection.CreateNewElement()
		/// </summary>
		/// <returns>ConfigurationElementCollection.CreateNewElement()</returns>
		protected override ConfigurationElement CreateNewElement()
		{
			return new DigitalSignerElement();
		}
		/// <summary>
		/// ConfigurationElementCollection.GetElementKey()
		/// </summary>
		/// <param name="element">ConfigurationElementCollection.GetElementKey()</param>
		/// <returns>ConfigurationElementCollection.GetElementKey()</returns>
		protected override object GetElementKey(ConfigurationElement element)
		{
			DigitalSignerElement plugin = element as DigitalSignerElement;
			if (plugin != null)
			{
				return plugin.DocumentExtension;
			}
			else
				throw new ConfigurationErrorsException(Resources.Messages.exception_DigitalSign_Configuration_DigitalSignerElementCollection_NotValidElements);
		}
	}
}
